| Home | Code/Games | About me |
|---|
a python executable to play a number guessing game wich you can choose the difficulty of (esier than the other one).
download
The code:
import random
from time import sleep
ng ="""
* * * * * *
* * * * *
* * * *
* * * * * * *** * *
* * * * * * * * * * *
---------------------------------------
"""
print(ng)
# defiens the range
def choose_dificulty():
global difficulty
difficulty = input("\nhighest number in the range: ")
# creates the answer
def create_answer():
global answer
answer = random.randint(1, int(difficulty))
global answer_range
answer_range = int(difficulty)
def check_answer():
person_input = input("Guess my number (1-{}): ".format(answer_range))
if str(answer) == str(person_input):
print("That is correct")
else:
continue_var = input("Wrong, continue? (y/n) ")
if str(continue_var) == "y":
check_answer()
elif str(continue_var) == "n":
pass
def game():
choose_dificulty()
create_answer()
check_answer()
running = True
while running:
game()
again = input("play again? (y/n) ")
if str(again) == "y":
pass
elif str(again) == "n":
running = False
goodbye ="""
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░▄▄▀▀▀▀▀▄░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░▄▀░░░░░░░▀▄░░░░░░░░░░░░░░░░░░░░░░░░░░
░▄▀░░░▄▄░░░░▀▀▀▀▀▀▀▄▄▀▀▀▀▀▀▀▀▀▀▀▀▄▄░░░░
░█░░░░██░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▄░░
░█░░░░██▄████▄░██▄░░░░▄██░▄████▄░░░░▀▄░
░█░░░░██▀░░▀██▄░██▄░░██▀░██▀░▄██░░░░░█░
░█░░░░██░░░░███░░█████▀░░██▄█▀▀░░░░░░█░
░█░░░░███▄▄███▀░░░▀██▀░░░▀██▄▄▄██░░░░█░
░▀▄░░░░▀▀▀▀▀▀░░░░░██▀░░░░░░▀▀▀▀▀░░░░░█░
░░▀▄░░░░░░░░░░░░░██▀░░░▄▄░░░░░░░░░▄▄▀░░
░░░░▀▀▀▀▀▀▀▀▀▄░░░▀▀░░░▄▀░▀▀▀▀▀▀▀▀▀░░░░░
░░░░░░░░░░░░░▀▄░░░░░░▄▀░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░▀▀▀▀▀▀░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
"""
print(goodbye)
sleep(1)